<?php
class GoodsPrice extends BaseBean{
    
    protected $_table= "tb_goods_price";
    protected $_primarykey= "id";
    protected $_table_alias= "a";

    public function generateSql(){
        return "select a.*,b.name as price_type from tb_goods_price a left join tb_price_type b on a.price_type_id = b.id ";
    }

    public function insertItem(){
        $this->set("create_date",date('Y-m-d',time()));
        $num =$this->connection->fetchColumn("select max(num) as num from tb_goods_price where goods_id=".$this->get("goods_id"))+1;
        $this->set("num",$num);
        $num = 1000 + $num;
        $this->set("seq", substr($num."",1));
        parent::insertItem();
    }

}
?>